package com.yangrd.airship.generator.support.utils;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * @author yangrd
 * @date 2021/11/12
 */
public class HumpUtils {

    private static final Pattern LINE_PATTERN = Pattern.compile("_(\\w)");

    /**
     * 下划线转驼峰
     */
    public static String lineToHump(String str) {
        str = str.toLowerCase();
        Matcher matcher = LINE_PATTERN.matcher(str);
        StringBuffer sb = new StringBuffer();
        while (matcher.find()) {
            matcher.appendReplacement(sb, matcher.group(1).toUpperCase());
        }
        matcher.appendTail(sb);
        return sb.toString();
    }


}
